package com.simdo.g768.Bean;

import com.g768.Bean.UeidBean;
import com.g768.MessageControl.MessageController;
import com.simdo.g768.Bean.object.ControlConfig;
import com.simdo.g768.Bean.object.TraceConfig;
import com.simdo.g768.Bean.object.Trace_cfg;
import com.simdo.g768.MainActivity;
import com.simdo.g768.R;
import com.simdo.g768.Util.DateUtil;
import com.simdo.g768.Util.GsonUtil;
import com.simdo.g768.ZApplication;

import java.util.HashMap;

public class HistoryBean{

    private boolean checked;
    /** 模式-  0 自动、1 名单、2 专业 3 专业 自配置PCI  反管控：4、全运营商、5、移动广电、6、联通电信、7、通道管理模式*/
    private int mode;
    /** 建立时间 */
    private long createTime;
    /** 最新开启时间 */
    private String startTime;

    private String name;

    private HashMap<Integer, TraceConfig> configMap;

    public HistoryBean(int mode) {
        this.checked = false;
        this.mode = mode;

        this.createTime = System.currentTimeMillis();
        this.startTime = "00:00:00";
        this.name = "";

        configMap = new HashMap<>();
        for (int i = 0; i < 6; i++){
            configMap.put(i, GsonUtil.getPerson(MessageController.build().templateTraceConfigCell().toString(), TraceConfig.class));
        }
    }

    public HistoryBean(int mode, HashMap<Integer, TraceConfig> configMap) {
        this.checked = false;
        this.mode = mode;

        this.createTime = System.currentTimeMillis();
        this.startTime = "00:00:00";
        this.name = "";

        this.configMap = configMap;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isChecked() {
        return checked;
    }

    public void setChecked(boolean checked) {
        this.checked = checked;
    }

    public int getMode() {
        return mode;
    }

    public void setMode(int mode) {
        this.mode = mode;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public TraceConfig getConfig(int cell) {
        return configMap.get(cell);
    }

    public String getImsi(){
        switch (mode){
            case 4:
                return MainActivity.getInstance().getString(R.string.all_yun_ying_shang);
            case 5:
                return MainActivity.getInstance().getString(R.string.yd_gd);
            case 6:
                return MainActivity.getInstance().getString(R.string.ld_dx);
            case 7:
                return MainActivity.getInstance().getString(R.string.cell_manage_mode);
        }
        if (configMap.get(0).getTrace_cfg().getImsi_num() == 0) return "";
        return configMap.get(0).getTrace_cfg().getImsi_list().get(0).getImsi();
    }

    public void setImsi(String imsi){
        for (int i = 0; i < 6; i++){
            Trace_cfg traceCfg = configMap.get(i).getTrace_cfg();
            if (traceCfg.getImsi_num() == 0) {
                traceCfg.setImsi_num(1);
                traceCfg.getImsi_list().add(new UeidBean(imsi, ""));
            }else traceCfg.getImsi_list().get(0).setImsi(imsi);
        }
    }

    public void setConfig(int cell, TraceConfig traceConfig) {
        this.configMap.put(cell, traceConfig);
    }

    public HashMap<Integer, TraceConfig> getTraceConfigMap() {
        return configMap;
    }
}
